package com.qq.xrx1002.androidgame;

import org.cocos2d.actions.CCScheduler;

import java.util.ArrayList;

/**
 * Created by Alyson on 2018/11/27.
 */

public abstract class ShooterPlant extends Plant {

    private ArrayList<Bullet> bullets;//定义数组存放子弹
    private boolean isAttack;//是否攻击

    public ShooterPlant(String format, int number) {
        super(format, number);
        bullets=new ArrayList<>();
    }
    public void attackZombie(){//攻击僵尸
        if (!isAttack){
            isAttack=true;
            CCScheduler.sharedScheduler().schedule("createBullet",this,
                    5,false);//设置定时器，每隔5秒发出11次子弹
        }
    }
    public void stopAttackZombie(){//停止攻击
        if (isAttack){
            isAttack=false;
            CCScheduler.sharedScheduler().unschedule("createBullet",this);
        }
    }

    public ArrayList<Bullet> getBullets() {
        return bullets;
    }

    public void setBullets(ArrayList<Bullet> bullets) {
        this.bullets = bullets;
    }
    public abstract void createBullet(float t);//设置抽象方法创建子弹
}
